package com.esd.vo;

import java.util.HashMap;
import java.util.List;


/**
 * 通用的返回类
 * 
 * @author ldw
 *
 */
public class ReturnResult extends HashMap<String, Object> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public static final String notice = "notice";
	public static final String message = "message";
	//存集合的信息key
	private static final String dataListName = "entity";
	
	public ReturnResult() {
		super();
	}

	public ReturnResult(Boolean notice, Object message) {
		super();
		this.put(ReturnResult.notice, notice);
		this.put(ReturnResult.message, message);
	}

	/**
	 * 成功返回ReturnResult 提示信息：操作成功
	 * 
	 * @return
	 */
	public static ReturnResult success() {
		return new ReturnResult(Boolean.TRUE, "操作成功!");
	}
	public static ReturnResult success1(String[] fileNames) {
		return new ReturnResult(Boolean.TRUE, fileNames);
	}
	
	public static ReturnResult storeData(Object obj) {
		return new ReturnResult(Boolean.TRUE, "操作成功!").add(dataListName, obj);
	}

	/**
	 * 成功返回ReturnResult
	 * 
	 * @param message：操作成功，需要返回的信息
	 * @return
	 */
	public static ReturnResult success(String message) {
		return new ReturnResult(Boolean.TRUE, message);
	}

	/**
	 * 失败返回ReturnResult对象 提示信息：操作失败
	 * 
	 * @return
	 */
	public static ReturnResult fail() {
		return new ReturnResult(Boolean.FALSE, "操作失败");
	}

	public static ReturnResult fail(String message) {
		return new ReturnResult(Boolean.FALSE, message);
	}
	
	/**
	 * 链式增加：返回需要的信息
	 * @param key
	 * @param value
	 * @return
	 */
	public ReturnResult add(String key, Object value){
		this.put(key, value);
		return this;
	}
}
